import folium.plugins as plugins
import folium
import pandas as pd

tiles = 'https://wprd01.is.autonavi.com/appmaptile?x={x}&y={y}&z={z}&lang=zh_cn&size=1&scl=1&style=7'

data = pd.read_csv('D:\桌面\考研大数据\地图可视化\data\大学（维度_经度）.csv',
                   encoding='GBK', header=0)
# print(data.head())
incidents = folium.map.FeatureGroup()       #实例化
for lat, lng, in zip(data['维度'], data['经度']):
    incidents.add_child(
        folium.CircleMarker(
            [lat, lng],
            radius=4,       # 设置标点的大小
            color='yellow',
            fill=True,
            fill_color='red',
            fill_opacity=0.4
        )
    )
#创建地图
uni_distribution = folium.Map([39.99, 116.31],  # 坐标范围自己设置,  维度/经度
                              tiles=tiles,      #地图样式
                              attr='高德-常规图',
                              zoom_start=5,  # 地图打开时聚焦大小，越大越详细
                              # zoom_start=10,
                              control_scale=True,
                              width='100%'
                              )
uni_distribution.add_child(incidents)   #添加实例

latitudes = list(data['维度'])
longitudes = list(data['经度'])
labels = list(data['大学名'])       #添加标签
for lat, lng, label in zip(latitudes, longitudes, labels):
    folium.Marker([lat, lng], popup=label).add_to(uni_distribution)    
# add incidents to map
uni_distribution.add_child(incidents)
uni_distribution.save("D:\桌面\考研大数据\地图可视化\index.html")
